import { getStaticsConfig } from '@/api/my'
const ERR_OK = 200
export default {
  data () {
    return {
      shops: null,
      config: null
    }
  },
  created () {
    this._getStaticsConfig()
  },
  methods: {
    getShopName (id) {
      const fIndex = this.shops.findIndex((item, index) => {
        return parseInt(item.id) === parseInt(id)
      })
      if (fIndex >= 0) {
        return this.shops[fIndex].name
      }
    },
    _getStaticsConfig () {
      getStaticsConfig()
        .then(res => {
          if (res.code === ERR_OK) {
            this.shops = res.data.shop
            this.config = res.data
          }
        })
        .catch(err => {
          console.log(err)
        })
    }
  }
}
